package com.example.service.Impl;
import com.example.common.exception.BaseException;
import com.example.entity.Travel;
import com.example.entity.dto.TravelSearch;
import com.example.entity.vo.TravelVO;
import com.example.mapper.TravelMapper;
import com.example.service.TravelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.sql.Date;
import java.util.List;


@Service
public class TravelServiceImpl implements TravelService {


    @Value("${file.upload-folder}")
    private String filePath;
    @Autowired
    private TravelMapper travelMapper;

    /**
     * 获取当前项目用车
     * @param projectId
     * @return
     */
    public List<TravelVO> findByProjectId(int projectId,String time){
        return travelMapper.findByProjectId(projectId,time);
    }

    /**
     * 新增当前项目用车
     * @param travel
     */
    public void addTravel(Travel travel) {
        travelMapper.addTravel(travel);
    }

    /**
     * 更新当前用车
     * @param travel
     */
    public void updataTravelById(Travel travel) {
        travelMapper.updataTravelById(travel);
    }

    /**
     * 获取当前用车
     * @param id
     * @return
     */
    public TravelVO findById(int id) {
        return travelMapper.findById(id);
    }

    /**
     * 删除用车
     * @param id
     */
    public void deleteTravel(int id) {
        travelMapper.delete(id);
    }

    /**
     * 用车查询
     * @return
     */
    public List<TravelVO> search(TravelSearch travelSearch) {
        return travelMapper.search(travelSearch);
    }
}
